package com.yzd.xander.dao.impl;

import com.yzd.xander.dao.QunInfoDao;
import com.yzd.xander.entity.QunInfo;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by YE on 2018-06-06.
 */
@Repository("qunInfoDao")
public class QunInfoDaoImpl extends HibernateDaoSupport implements QunInfoDao {

    @Override
    public QunInfo getQunInfo(int Qun) {
        Session session = getHibernateTemplate().getSessionFactory().openSession();
        List<QunInfo> list=session.createSQLQuery("{Call SearchQunInfo(" + Qun + ")}").addEntity(QunInfo.class).list();
        return list.size()>0?list.get(0):null;
    }

    @Autowired
    public void setMySessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }
}
